package com.example.backend.service.mysql.user.impl;

import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.backend.entitly.mysql.user.UserAuth;
import com.example.backend.mapper.mysql.user.UserAuthMapper;
import com.example.backend.service.mysql.user.UserAuthService;
import org.springframework.stereotype.Service;

/**
 * @author 1
 * @description 针对表【user_auth(用户认证方式表)】的数据库操作Service实现
 * @createDate 2025-06-04 10:09:21
 */
@Service
public class UserAuthServiceImpl extends ServiceImpl<UserAuthMapper, UserAuth>
        implements UserAuthService {

    @Override
    public UserAuth getByUsername(String username) {
        return new LambdaQueryChainWrapper<>(getBaseMapper()).eq(UserAuth::getIdentifier, username).one();
    }

    @Override
    public boolean savaByUser(String username, String password, Integer userId, Integer authMethodId) {
        UserAuth userAuth = new UserAuth();
        userAuth.setIdentifier(username);
        userAuth.setCredential(password);
        userAuth.setAuthMethodId(authMethodId);
        userAuth.setUserId(Long.valueOf(userId));
        return save(userAuth);
    }
}




